home *** CD-ROM | disk | FTP | other *** search
- /* BEEP.C - Make a sound */
-
- #include "STDIO.H"
- #include "DOS.H"
- #include "TIME.H"
-
- main()
- {
- long freq = 0;
- long dur = 0;
- long a;
- int l,h;
- long ival;
- unsigned char clock[8];
- int timeval1,timeval2;
-
- printf("Enter frequency in Hz: ");
- scanf("%d",&freq);
- printf("Enter duration in 100ths Sec: ");
- scanf("%d",&dur);
-
- outp(67,182);
-
- a = 1193182L/freq;
- h = a/256;
- l = a-(h*256);
- outp(66,l);
- outp(66,h);
-
-
- getclk(clock);
- timeval1 = 100*clock[6]+clock[7];
- outp(97,(inp(97) | 3));
-
- ival = 0L;
- while (dur > ival)
- {
- getclk(clock);
- timeval2 = 100*clock[6]+clock[7];
- ival = timeval2 - timeval1;
- if (ival < 0L) ival = ival + 6000;
- }
- outp(97,(inp(97) & 252));
- }